import 'dart:io';

import 'package:flutter/material.dart';
import 'package:flutter_create_framework/provider/state_provider.dart';
import 'package:flutter_local_notifications/flutter_local_notifications.dart';
import 'package:provider/provider.dart';

class ServerProvider with ChangeNotifier{

//  服务
  HttpServer _httpServer;
  get httpServer => _httpServer;

  void setHttpServer(HttpServer httpServer){
    _httpServer = httpServer;
    notifyListeners();
  }

  void closeHttpServer(context)async{
    if(_httpServer!=null){
      _httpServer.close();
      Provider.of<StateProvider>(context,listen: false).setServerRun(false);
      await FlutterLocalNotificationsPlugin().cancelAll();
    }
    notifyListeners();
  }

}